package com.amumu.drama.common.modules.order.mapping;

import com.amumu.drama.common.base.mapstruct.BaseMapping;
import com.amumu.drama.common.constant.DeliveryStatusEnum;
import com.amumu.drama.common.constant.OrderStatusEnum;
import com.amumu.drama.common.constant.PayStatusEnum;
import com.amumu.drama.common.modules.delivery.dto.DeliveryOrderStatusQueryResp;
import com.amumu.drama.common.modules.order.dto.OmsOrderDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * @author sunzhuang
 * @date 2024/9/14 15:23
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc todo
 */

@Mapper(componentModel = "spring")
public interface DeliveryOrderStatusQueryRespMapping extends BaseMapping<OmsOrderDetail, DeliveryOrderStatusQueryResp> {
    DeliveryOrderStatusQueryRespMapping INSTANCE = Mappers.getMapper(DeliveryOrderStatusQueryRespMapping.class);

    /**
     * 正向映射的后置处理，List映射会自动继承此配置
     *
     * @param src
     * @param dest
     */
    @Override
    default void afterConvertTo(OmsOrderDetail src, DeliveryOrderStatusQueryResp dest) {
        dest.setOrderDetail(src);
        dest.setOrderStatusEnum(OrderStatusEnum.getByCode(src.getStatus()));
        dest.setPayStatusEnum(PayStatusEnum.getByCode(src.getPayStatus()));
        dest.setDeliveryStatusEnum(DeliveryStatusEnum.getByCode(src.getDeliveryStatus()));
        dest.setMsg(src.getNote());
    }
}
